package com.qijian.mold.util;

import cn.hutool.core.util.IdUtil;

/**
 * @author anni.zhu
 * @author anni.zhu@king-v.com
 * Created in 2025/3/29 19:35
 */
@FunctionalInterface
public interface IdGenerator<T> {
    /**
     * generate id
     * lambda interface only have one function need to be implemented
     *
     * @return id
     */
    T generate();

    /**
     * 生成 UUID
     */
    IdGenerator<String> UUID = IdUtil::randomUUID;


    /**
     * 生成雪花 ID
     */
    IdGenerator<Long> SNOW = IdUtil.getSnowflake(IdWorkerUtils.getWorkId(), IdWorkerUtils.getDataCenterId())::nextId;
}
